<!-- $Id: item_list.htm 16529 2009-08-12 05:38:57Z gaoshikao $ -->

{if $full_page}
{include file="pageheader.htm"}
{insert_scripts files="../js/utils.js,listtable.js"}

<!-- 商品搜索 -->
{include file="item_search.htm"}
<!-- 商品列表 -->
<form method="post" action="" name="listForm" onsubmit="return confirmSubmit(this)">
  <!-- start item list -->
  <div class="list-div" id="listDiv">
{/if}
<table cellpadding="3" cellspacing="1">
  <tr>
    <th>
      <input onclick='listTable.selectAll(this, "checkboxes")' type="checkbox" />
      <a href="javascript:listTable.sort('num_iid'); ">{$lang.num_iid}</a>{$sort_num_iid}
    </th>
    <th>{$lang.pic_url}</th>
    <th><a href="javascript:listTable.sort('title'); ">{$lang.title}</a>{$sort_title}</th>
    <th><a href="javascript:listTable.sort('price'); ">{$lang.price}</a>{$sort_price}</th>
    <th><a href="javascript:listTable.sort('commission'); ">{$lang.commission}</a>{$sort_commission}</th>
    <th><a href="javascript:listTable.sort('commission_rate'); ">{$lang.commission_rate}</a>{$sort_commission_rate}</th>
    <th><a href="javascript:listTable.sort('commission_num'); ">{$lang.commission_num}</a>{$sort_commission_num}</th>
    <th><a href="javascript:listTable.sort('commission_volume'); ">{$lang.commission_volume}</a>{$sort_commission_volume}</th>
    <th><a href="javascript:listTable.sort('is_convert'); ">{$lang.is_convert}</a>{$sort_is_convert}</th>
    <th><a href="javascript:listTable.sort('last_update'); ">{$lang.last_update}</a>{$sort_last_update}</th>
    <th>{$lang.handler}</th>
  <tr>
  {foreach from=$item_list item=item}
  <tr>
    <td><input type="checkbox" name="checkboxes[]" value="{$item.num_iid}" />{$item.num_iid}</td>
    <td align="center"><img src="{$item.pic_url}" width="100" /></td>
    <td class="first-cell"><span><a href="{$item.click_url}" target="_blank">{$item.title|escape:html}</a></span><br /><span style="font-weight:normal">{$item.iid}</span><br /><a href="item.php?act=list&nick={$item.nick}">{$item.nick}</a></td>
    <td align="center"><span>{$item.price}</span></td>
    <td align="center"><span>{$item.commission}</span></td>
    <td align="center"><span>{$item.commission_rate}</span></td>
    <td align="center"><span>{$item.commission_num}</span></td>
    <td align="center"><span>{$item.commission_volume}</span></td>
    <td align="center"><img src="images/{if $item.is_convert}yes{else}no{/if}.gif" onclick="listTable.toggle(this, 'toggle_is_convert', {$item.num_iid})" /></td>
    <td align="center"><span>{$item.last_update}</span></td>
    <td align="center">
      <a href="{$item.detail_url}" target="_blank" title="{$lang.view}"><img src="images/icon_view.gif" width="16" height="16" border="0" /></a>
      <a href="item.php?act=edit&num_iid={$item.num_iid}" title="{$lang.edit}"><img src="images/icon_edit.gif" width="16" height="16" border="0" /></a>
      <a href="javascript:;" onclick="listTable.remove({$item.num_iid}, '{$lang.trash_item_confirm}')" title="{$lang.trash}"><img src="images/icon_trash.gif" width="16" height="16" border="0" /></a>
    </td>
  </tr>
  {foreachelse}
  <tr><td class="no-records" colspan="10">{$lang.no_records}</td></tr>
  {/foreach}
</table>
<!-- end item list -->

<!-- 分页 -->
<table id="page-table" cellspacing="0">
  <tr>
    <td align="right" nowrap="true">
    {include file="page.htm"}
    </td>
  </tr>
</table>

{if $full_page}
</div>

<div>
  <input type="hidden" name="act" value="batch" />
  <select name="type" id="selAction" onchange="changeAction()">
    <option value="">{$lang.select_please}</option>
    <option value="update">{$lang.update}</option>
    <option value="trash">{$lang.remove}</option>
    <option value="move_to">{$lang.move_to}</option> 
  </select>
  <select name="target_cat" style="display:none">
    <option value="0">{$lang.select_please}</option>{$cat_list}
  </select>
  <input type="submit" value="{$lang.button_submit}" id="btnSubmit" name="btnSubmit" class="button" disabled="true" />
</div>
</form>

<script type="text/javascript">
  listTable.recordCount = {$record_count};
  listTable.pageCount = {$page_count};

  {foreach from=$filter item=item key=key}
  listTable.filter.{$key} = '{$item}';
  {/foreach}

  {literal}
  onload = function()
  {
    startCheckOrder(); // 开始检查订单
    document.forms['listForm'].reset();
  }

  /**
   * @param: bool ext 其他条件：用于转移分类
   */
  function confirmSubmit(frm, ext)
  {
      if (frm.elements['type'].value == 'trash')
      {
          return confirm(batch_trash_confirm);
      }
      else if (frm.elements['type'].value == 'move_to')
      {
          ext = (ext == undefined) ? true : ext;
          return ext && frm.elements['target_cat'].value != 0;
      }
      else if (frm.elements['type'].value == '')
      {
          return false;
      }
      else
      {
          return true;
      }
  }

  function changeAction()
  {
      var frm = document.forms['listForm'];

      // 切换分类列表的显示
      frm.elements['target_cat'].style.display = frm.elements['type'].value == 'move_to' ? '' : 'none';
			
      if (!document.getElementById('btnSubmit').disabled &&
          confirmSubmit(frm, false))
      {
          frm.submit();
      }
  }
{/literal}
</script>
{include file="pagefooter.htm"}
{/if}